<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        后台管理系统
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="./css/x-admin.css" media="all">
    <link rel="stylesheet" href="./lib/layui/css/layui.css">
</head>

<body>
<div class="x-body">
   <c:if test="${teacher!=null && cool==null}">
       <form class="layui-form layui-form-pane" >
           <input type="text" class="layui-hide" name="tid" value="${teacher.tid}">
           <div class="layui-form-item">
               <label for="L_titles1" class="layui-form-label">
                   账号:
               </label>
               <div class="layui-input-block">
                   <input type="text" id="L_titles1" name="tno" required lay-verify="title"
                          autocomplete="off" class="layui-input" readonly="readonly" value="${teacher.tno}">
               </div>
           </div>
           <div class="layui-form-item">
               <label for="L_titles2" class="layui-form-label">
                   密码:
               </label>
               <div class="layui-input-block">
                   <input type="password" id="L_titles2" name="tpwd" required lay-verify="title"
                          autocomplete="off" class="layui-input" value="${teacher.tpwd}">
               </div>
           </div>
           <div class="layui-form-item">
               <label for="L_titles3" class="layui-form-label">
                   姓名:
               </label>
               <div class="layui-input-block">
                   <input type="text" id="L_titles3" name="tname" required lay-verify="title"
                          autocomplete="off" class="layui-input" value="${teacher.tname}">
               </div>
           </div>
           <div class="layui-form-item">
               <label for="gender1" class="layui-form-label">
                   性别:
               </label>
               <div class="layui-input-block">
                   <c:if test="${teacher.tgender=='男'}">
                       <input type="radio" name="tgender" id="gender1" value="男" title="男" checked="checked">
                       <input type="radio" name="tgender" value="女" title="女">
                   </c:if>
                   <c:if test="${teacher.tgender=='女'}">
                       <input type="radio" name="tgender" id="gender1" value="男" title="男" >
                       <input type="radio" name="tgender" value="女" title="女" checked="checked">
                   </c:if>
               </div>
           </div>
           <div class="layui-form-item">
               <label for="addresss1" class="layui-form-label">
                   住址:
               </label>
               <div class="layui-input-block">
                   <input type="text" id="addresss1" name="taddress" required lay-verify="title"
                          autocomplete="off" class="layui-input" value="${teacher.taddress}">
               </div>
           </div>
           <div class="layui-form-item">
               <label for="tels1" class="layui-form-label">
                   电话:
               </label>
               <div class="layui-input-block">
                   <input type="text" id="tels1" name="ttel" required lay-verify="title"
                          autocomplete="off" class="layui-input" value="${teacher.ttel}">
               </div>
           </div>
           <div class="layui-form-item">
               <label for="emails1" class="layui-form-label">
                   邮箱:
               </label>
               <div class="layui-input-block">
                   <input type="text" id="emails1" name="temail" required lay-verify="title"
                          autocomplete="off" class="layui-input" value="${teacher.temail}">
               </div>
           </div>
           <div class="layui-form-item">
               <label class="layui-form-label">状态</label>
               <div class="layui-input-block">
                   <c:if test="${teacher.status==1}">
                       <input type="checkbox" checked="checked"  name="status" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
                   </c:if>
                   <c:if test="${teacher.status==0}">
                       <input type="checkbox"   name="status" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
                   </c:if>
               </div>
           </div>
           <div class="layui-form-item">
               <button class="layui-btn" lay-filter="add" lay-submit>
                   立即发布
               </button>
           </div>
       </form>
   </c:if>
    <c:if test="${teacher!=null && cool!=null}">
        <form class="layui-form layui-form-pane" >
            <input type="text" class="layui-hide" name="tid" value="${teacher.tid}">
            <div class="layui-form-item">
                <label for="L_titles1" class="layui-form-label">
                    账号:
                </label>
                <div class="layui-input-block">
                    <input type="text" id="L_titless3" readonly="readonly"  name="tno" required lay-verify="title"
                           autocomplete="off" class="layui-input" readonly="readonly" value="${teacher.tno}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_titles2" class="layui-form-label">
                    密码:
                </label>
                <div class="layui-input-block">
                    <input type="password" id="L_titlesss2" readonly="readonly" name="tpwd" required lay-verify="title"
                           autocomplete="off" class="layui-input" value="${teacher.tpwd}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_titles3" class="layui-form-label">
                    姓名:
                </label>
                <div class="layui-input-block">
                    <input type="text" id="L_titlessss3" readonly="readonly" name="tname" required lay-verify="title"
                           autocomplete="off" class="layui-input" value="${teacher.tname}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="gender1" class="layui-form-label">
                    性别:
                </label>
                <div class="layui-input-block">
                    <c:if test="${teacher.tgender=='男'}">
                        <input type="radio" name="tgender" id="gender1" value="男" title="男" checked="checked">
                        <input type="radio" name="tgender" value="女" title="女">
                    </c:if>
                    <c:if test="${teacher.tgender=='女'}">
                        <input type="radio" name="tgender" id="gender1" value="男" title="男" >
                        <input type="radio" name="tgender" value="女" title="女" checked="checked">
                    </c:if>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="addresss1" class="layui-form-label">
                    住址:
                </label>
                <div class="layui-input-block">
                    <input type="text" id="addresssss1" readonly="readonly" name="taddress" required lay-verify="title"
                           autocomplete="off" class="layui-input" value="${teacher.taddress}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="tels1" class="layui-form-label">
                    电话:
                </label>
                <div class="layui-input-block">
                    <input type="text" id="telssss11" readonly="readonly" name="ttel" required lay-verify="title"
                           autocomplete="off" class="layui-input" value="${teacher.ttel}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="emails1" class="layui-form-label">
                    邮箱:
                </label>
                <div class="layui-input-block">
                    <input type="text" id="emailsss1"  readonly="readonly" name="temail" required lay-verify="title"
                           autocomplete="off" class="layui-input" value="${teacher.temail}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <c:if test="${teacher.status==1}">
                        <input type="checkbox" checked="checked"  name="status" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
                    </c:if>
                    <c:if test="${teacher.status==0}">
                        <input type="checkbox"   name="status" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
                    </c:if>
                </div>
            </div>
<%--            <div class="layui-form-item">--%>
<%--                <button class="layui-btn" lay-filter="add" lay-submit>--%>
<%--                    立即发布--%>
<%--                </button>--%>
<%--            </div>--%>
        </form>
    </c:if>
    <c:if test="${teacher==null}">
    <form class="layui-form layui-form-pane" >
        <div class="layui-form-item">
            <label for="L_title" class="layui-form-label">
                账号:
            </label>
            <div class="layui-input-block">
                <input type="text" id="L_title" name="tno" required lay-verify="title"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_title1" class="layui-form-label">
                密码:
            </label>
            <div class="layui-input-block">
                <input type="password" id="L_title1" name="tpwd" required lay-verify="title"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_title2" class="layui-form-label">
                姓名:
            </label>
            <div class="layui-input-block">
                <input type="text" id="L_title2" name="tname" required lay-verify="title"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="gender" class="layui-form-label">
                性别:
            </label>
            <div class="layui-input-block">
                <input type="radio" name="tgender" id="gender" value="男" title="男" checked="checked">
                <input type="radio" name="tgender" value="女" title="女">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="address" class="layui-form-label">
                住址:
            </label>
            <div class="layui-input-block">
                <input type="text" id="address" name="taddress" required lay-verify="title"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="tel" class="layui-form-label">
                电话:
            </label>
            <div class="layui-input-block">
                <input type="text" id="tel" name="ttel" required lay-verify="title"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="email" class="layui-form-label">
                邮箱:
            </label>
            <div class="layui-input-block">
                <input type="text" id="email" name="temail" required lay-verify="title"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="checkbox" checked="checked"  name="status" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" lay-filter="add" lay-submit>
                立即发布
            </button>
        </div>
    </form>
    </c:if>
</div>
<script src="./lib/layui/layui.js" charset="utf-8">
</script>
<script src="./js/x-layui.js" charset="utf-8"></script>
<script src="./js/common.js" charset="utf-8"></script>
<script>
    layui.use(['form','layer','layedit'], function(){
        $ = layui.jquery;
        var form = layui.form()
            ,layer = layui.layer
            ,layedit = layui.layedit;

        //监听提交
       form.on('submit(add)',function (data) {
           let res=post('/teacheradd',data.field);
           if(res.code==0){
               layer.alert('操作成功！',{icon:6},function (){
                   //获得frame 索引
                   var index= parent.layer.getFrameIndex(window.name);
                   //关闭当前frame
                   parent.layer.close(index);
               });
           }else layer.alert('失败',{icon:5});
                return false;
       });
    });
</script>

</body>

</html>
